package marmalius;
/*
	//fichier d'entree clavier
	//creer par jpp (prof de prog java)
	//modifie par Metos [EOAH]
*/

import java.io.*;

public class InputKey {

	public InputKey () {
		
	}

	public static int readInt () {
		boolean flag = false;
		int i = -1;
		while (!flag) {
			String s = "";
			try {
				char c;
				for (c = (char)System.in.read(); c != '\n' && c != '\r'; c = (char)System.in.read())
					s = s + c;
				if (c == '\r')
					c = (char)System.in.read();
				i = Integer.parseInt(s);
				flag = true;
			}
			catch (IOException ioexception) {
				System.out.println("Erreur");
			}
			catch (NumberFormatException numberformatexception) {
				System.out.println("Erreur entrer un nombre");
			}
		}
		return i;
	}

	public static int readInt (String s) {
		System.out.print(s);
		return readInt();
	}

	public static float readFloat () {
		boolean flag = false;
		float f = 0.0F;
		while (!flag) {
			String s = "";
			try {
				char c;
				for (c = (char)System.in.read(); c != '\n' && c != '\r'; c = (char)System.in.read())
					s = s + c;
				if (c == '\r')
					c = (char)System.in.read();
				f = Float.parseFloat(s);
				flag = true;
			}
			catch (IOException ioexception) {
				System.out.println("Erreur");
			}
			catch (NumberFormatException numberformatexception) {
				System.out.println("Erreur entrez un nombre");
			}
		}
		return f;
	}

	public static float readFloat (String s) {
		System.out.print(s);
		return readFloat();
	}

	public static double readDouble () {
		boolean flag = false;
		double d = 0.0D;
		while (!flag) {
			String s = "";
			try {
				char c;
				for (c = (char)System.in.read(); c != '\n' && c != '\r'; c = (char)System.in.read())
					s = s + c;
				if (c == '\r')
					c = (char)System.in.read();
				d = Float.parseFloat(s);
				flag = true;
			}
			catch (IOException ioexception) {
				System.out.println("Erreur");
			}
			catch (NumberFormatException numberformatexception) {
				System.out.println("Erreur entrez un nombre");
			}
		}
		return d;
	}

	public static double readDouble (String s) {
		System.out.print(s);
		return readDouble();
	}

	public static char readChar () {
		char c = ' ';
		try {
			char c1 = (char)System.in.read();
			c = c1;
			for (; c1 != '\n' && c1 != '\r'; c1 = (char)System.in.read());
			if (c1 == '\r')
				c1 = (char)System.in.read();
		}
		catch (IOException ioexception) {
			System.out.println("Erreur");
		}
		return c;
	}

	public static char readChar (String s) {
		System.out.print(s);
		return readChar();
	}

	public static String readString () {
		String s = "";
		try {
			char c;
			for (c = (char)System.in.read(); c != '\n' && c != '\r'; c = (char)System.in.read())
				s = s + c;
			if (c == '\r')
				c = (char)System.in.read();
		}
		catch (IOException ioexception) {
			System.out.println("Erreur");
		}
		return s;
	}

	public static String readString (String s) {
		System.out.print(s);
		return readString();
	}

	public static void attente () {
		try {
			System.in.read();
		}
		catch(IOException ioexception) { }
	}
}